//
//  AllView.m
//  Streaming
//
//  Created by 韩一博 on 15/6/30.
//  Copyright (c) 2015年 liuxun. All rights reserved.
//

#import "AllView.h"

@implementation AllView

- (void)dealloc
{
    [self.image release];
    [self.label release];
    [self.hotBack release];
    
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        if (WIDTH == 320 && HEIGHT == 568) {
            [self create5];
        }
        if (WIDTH == 414 && HEIGHT == 736) {
            [self createPlus];
        }
        if (WIDTH == 375 && HEIGHT == 667){
            [self create6];
        }

    }
    return self;
}


- (void)create5
{
    self.hotBack = [[UIView alloc]initWithFrame:CGRectMake(0, 0,self.frame.size.width,260)];
    self.hotBack.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.hotBack];
    [_hotBack autorelease];
    
    
    self.image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 30)];
    [self.hotBack addSubview:self.image];
    self.image.layer.shadowColor = [UIColor blackColor].CGColor;
    self.image.layer.shadowOffset = CGSizeMake(0, 3);
    self.image.layer.shadowOpacity = 0.9;
    self.image.layer.shadowRadius = 10.0;
    self.image.userInteractionEnabled = YES;
    [_image autorelease];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, self.image.frame.size.width, self.image.frame.size.height);
    [button addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    [self.image addSubview:button];
    
    
    UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(0, self.image.frame.size.height-30, WIDTH, 30)];
    backView.backgroundColor = [UIColor blackColor];
    backView.alpha = 0.7;
    [self.image addSubview:backView];
    [backView autorelease];
    
    self.label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, WIDTH, 30)];
    self.label.font = [UIFont boldSystemFontOfSize:20];
    self.label.textColor = [UIColor whiteColor];
    [backView addSubview:self.label];
    [_label autorelease];
    
}

- (void)create6
{
    
    self.image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height-30)];
    [self addSubview:self.image];
    self.image.layer.shadowColor = [UIColor blackColor].CGColor;
    self.image.layer.shadowOffset = CGSizeMake(0, 3);
    self.image.layer.shadowOpacity = 0.9;
    self.image.layer.shadowRadius = 10.0;
    self.image.userInteractionEnabled = YES;
    [_image autorelease];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, self.image.frame.size.width, self.image.frame.size.height);
    [button addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    [self.image addSubview:button];
    
    
    UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(0, self.image.frame.size.height-30, WIDTH, 30)];
    backView.backgroundColor = [UIColor blackColor];
    backView.alpha = 0.7;
    [self.image addSubview:backView];
    [backView autorelease];
    
    self.label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, WIDTH, 30)];
    self.label.font = [UIFont boldSystemFontOfSize:20];
    self.label.textColor = [UIColor whiteColor];
    [backView addSubview:self.label];
    [_label autorelease];

}

- (void)createPlus
{
    self.hotBack = [[UIView alloc]initWithFrame:CGRectMake(0, 0,self.frame.size.width,280)];
    self.hotBack.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.hotBack];
    [_hotBack autorelease];
    
    self.image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.hotBack.frame.size.width, self.hotBack.frame.size.height)];
    [self.hotBack addSubview:self.image];
    self.image.layer.shadowColor = [UIColor blackColor].CGColor;
    self.image.layer.shadowOffset = CGSizeMake(0, 3);
    self.image.layer.shadowOpacity = 0.9;
    self.image.layer.shadowRadius = 10.0;
    self.image.userInteractionEnabled = YES;
    [_image autorelease];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, self.image.frame.size.width, self.image.frame.size.height);
    [button addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    [self.image addSubview:button];
    
    
    UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(0, self.image.frame.size.height-30, WIDTH, 30)];
    backView.backgroundColor = [UIColor blackColor];
    backView.alpha = 0.7;
    [self.image addSubview:backView];
    [backView autorelease];
    
    self.label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, WIDTH, 30)];
    self.label.font = [UIFont boldSystemFontOfSize:20];
    self.label.textColor = [UIColor whiteColor];
    [backView addSubview:self.label];
    [_label autorelease];
    
}


- (void)buttonAction
{
    [self.allViewDelegate presentAllView];
}

- (void)setAllModel:(AllViewModel *)AllModel
{
    if (_AllModel != AllModel) {
        [_AllModel release];
        _AllModel = [AllModel retain];
        
    }
    NSURL *url = [NSURL URLWithString:self.AllModel.allImageUrl];
    [self.image sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"111111.png"]];
    self.label.text = self.AllModel.allTitle;
    
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
